"""
Case Type   : fullsql
Case Name   : 校验full sql关键字段一致性
Create At   : 2022/02/08
Owner       : zhao-pengcheng-g
Description :
    1.检查参数，修改配置:enable_copy_server_files=on
    2.检查参数，修改配置:instr_unique_sql_count=100000
    3.创建表
    4.导入数据
    5.查询系统视图
    6.执行analyze,查询系统视图
    7.插入数据,查询系统视图
    8.执行checkpoint,查询系统视图
    9.执行vacuum,查询系统视图
    10.更新数据,查询系统视图
    11.删除数据,查询系统视图
    12.环境清理
Expect      :
    1.修改参数成功
    2.修改参数成功
    3.创建成功
    4.导入成功
    5.查询有数据
    6.查询有数据
    7.查询有数据
    8.查询有数据
    9.查询有数据
    10.查询有数据
    11.查询有数据
    12.环境清理成功
History     :
    modified by l1azzzy2024/12/9 优化scp文件权限问题
"""

import os
import unittest
from yat.test import Node
from yat.test import macro
from testcase.utils.CommonSH import CommonSH
from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger
from testcase.utils.Common import Common


class Fullsql(unittest.TestCase):
    def setUp(self):
        self.logger = Logger()
        text = '---Opengauss_Function_Fullsql_Case0014 start---'
        self.logger.info(text)
        self.userNode = Node('PrimaryDbUser')
        self.rootNode = Node('PrimaryRoot')
        self.sh_primy = CommonSH('PrimaryDbUser')
        self.constant = Constant()
        self.common = Common()
        self.table_name = 't_item_fullsql_0014'
        self.table_path = os.path.join(r'/home', self.userNode.ssh_user,
                                       'copy_tables')
        text = '---prestep1:修改机器umask---'
        self.logger.info(text)
        umask_cmd = f"umask 0022;"
        self.rootNode.sh(umask_cmd).result()
        text = '---step1:检查参数，修改配置:enable_copy_server_files=on,' \
               'expect:成功---'
        self.logger.info(text)
        self.config_copy = 'enable_copy_server_files'
        self.show_copy_cmd = f'show {self.config_copy};'
        check_copy = self.sh_primy.execut_db_sql(self.show_copy_cmd)
        self.logger.info(check_copy)
        self.copy_default = check_copy.splitlines()[-2].strip()
        if 'on' != self.copy_default:
            result = self.sh_primy.execute_gsguc('reload',
                                                 self.constant.GSGUC_SUCCESS_MSG,
                                                 f'{self.config_copy}=on')
            self.assertTrue(result, '参数修改失败')
        chk_copy_msg = self.sh_primy.execut_db_sql(self.show_copy_cmd)
        self.logger.info(chk_copy_msg)
        self.common.equal_sql_mdg(chk_copy_msg, self.config_copy, 'on',
                                  '(1 row)', flag='1')
        text = '---step2:检查参数，修改配置:instr_unique_sql_count=100000,' \
               'expect:成功---'
        self.logger.info(text)
        self.config_instr = 'instr_unique_sql_count'
        self.show_instr_cmd = f'show {self.config_instr};'
        check_instr = self.sh_primy.execut_db_sql(self.show_instr_cmd)
        self.logger.info(check_instr)
        self.instr_default = check_instr.splitlines()[-2].strip()
        if '100000' != self.instr_default:
            result = self.sh_primy.execute_gsguc('reload',
                                                 self.constant.GSGUC_SUCCESS_MSG,
                                                 f'{self.config_instr}=100000')
            self.assertTrue(result, '参数修改失败')
        chk_instr_msg = self.sh_primy.execut_db_sql(self.show_instr_cmd)
        self.logger.info(chk_instr_msg)
        self.common.equal_sql_mdg(chk_instr_msg, self.config_instr, '100000',
                                  '(1 row)', flag='1')

        text = '---step3:清理历史记录，创建表,expect;成功---'
        self.logger.info(text)
        creat_cmd = f'''select reset_unique_sql('global', 'all', 1);
            drop table if exists {self.table_name};
            create table {self.table_name}
            ( 
            i_item_sk                 integer               not null,
            i_item_id                 char(16)              not null,
            i_rec_start_date          date                          ,
            i_rec_end_date            date                          ,
            i_item_desc               varchar(200)                  ,
            i_current_price           decimal(7,2)                  ,
            i_wholesale_cost          decimal(7,2)                  ,
            i_brand_id                integer                       ,
            i_brand                   char(50)                      ,
            i_class_id                integer                       ,
            i_class                   char(50)                      ,
            i_category_id             integer                       ,
            i_category                char(50)                      ,
            i_manufact_id             integer                       ,
            i_manufact                char(50)                      ,
            i_size                    char(20)                      ,
            i_formulation             char(20)                      ,
            i_color                   char(20)                      ,
            i_units                   char(10)                      ,
            i_container               char(10)                      ,
            i_manager_id              integer                       ,
            i_product_name            char(50)
            ) ;'''
        create_msg = self.sh_primy.execut_db_sql(creat_cmd)
        self.logger.info(create_msg)
        self.assertIn('reset_unique_sql' and '(1 row)',
                      create_msg, '执行失败:' + text)
        self.assertIn(self.constant.DROP_TABLE_SUCCESS
                      and self.constant.CREATE_TABLE_SUCCESS,
                      create_msg, '执行失败:' + text)

        text = '---step4:导入数据，expect:导入成功---'
        self.logger.info(text)
        self.common.scp_file(self.userNode, 'item.txt',
                             self.table_path)
        item_path = os.path.join(self.table_path, 'item.txt')
        chmod_cmd = f"chmod 755 {item_path};"
        self.rootNode.sh(chmod_cmd).result()
        copy_cmd = f'''copy {self.table_name} from '{item_path}' \
                    DELIMITER as ',' NULL as '';
                    select pg_sleep(30);'''
        self.logger.info(copy_cmd)
        copy_msg = self.sh_primy.execut_db_sql(copy_cmd)
        self.logger.info(copy_msg)
        self.assertIn(self.constant.copy_success_msg,
                      copy_msg, '执行失败:' + text)

    def test_fullsql(self):
        text = "---step5:查询系统视图,expect:查询有数据---"
        self.logger.info(text)
        sql_cmd = f'''select 
                n_hard_parse,n_returned_rows,n_tuples_fetched,
                n_tuples_returned, n_tuples_inserted,n_tuples_updated,
                n_tuples_deleted,n_blocks_fetched,n_blocks_hit, n_soft_parse 
            from dbe_perf.statement 
            where query like 'copy {self.table_name} from %';'''
        sql_msg = self.sh_primy.execut_db_sql(sql_cmd, dbname='postgres')
        self.logger.info(sql_msg)
        row_num = (sql_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)
        select_cmd = f'''select 
                sum(n_hard_parse) as n_hard_parse,
                sum(n_returned_rows) as n_returned_rows,
                sum(n_tuples_fetched) as n_tuples_fetched,
                sum(n_tuples_returned) as n_tuples_returned,
                sum(n_tuples_inserted) as n_tuples_inserted,
                sum(n_tuples_updated) as n_tuples_updated, 
                sum(n_tuples_deleted) as n_tuples_deleted,
                sum(n_blocks_fetched)as n_blocks_fetched, 
                sum(n_blocks_hit)as n_blocks_hit, 
                sum(n_soft_parse) as n_soft_parse 
            from dbe_perf.get_global_full_sql_by_timestamp\
                (now()-interval'5 min', now()) 
            where unique_query_id=(select unique_sql_id 
                from dbe_perf.statement 
                where query like 'copy {self.table_name}%') 
            minus (select 
                n_hard_parse,n_returned_rows,n_tuples_fetched,
                n_tuples_returned,n_tuples_inserted,n_tuples_updated,
                n_tuples_deleted,n_blocks_fetched,n_blocks_hit,n_soft_parse 
                from dbe_perf.statement 
                where query like 'copy {self.table_name}%');'''
        select_msg = self.sh_primy.execut_db_sql(select_cmd, dbname='postgres')
        self.logger.info(select_msg)
        row_num = (select_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)

        text = "---step6:执行analyze,查询系统视图," \
               "expect:analyze成功，查询有数据 ---"
        self.logger.info(text)
        sql_cmd = f'analyze {self.table_name};' \
                  f'select pg_sleep(30);'
        sql_msg = self.sh_primy.execut_db_sql(sql_cmd)
        self.logger.info(sql_msg)
        self.assertIn(self.constant.ANALYZE_SUCCESS_MSG,
                      sql_msg, '执行失败:' + text)
        sql_cmd = f'''select 
                n_hard_parse,n_returned_rows,n_tuples_fetched,
                n_tuples_returned, n_tuples_inserted,n_tuples_updated,
                n_tuples_deleted,n_blocks_fetched,n_blocks_hit n_soft_parse 
            from dbe_perf.statement 
            where query like 'analyze {self.table_name}%';'''
        sql_msg = self.sh_primy.execut_db_sql(sql_cmd, dbname='postgres')
        self.logger.info(sql_msg)
        row_num = (sql_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)
        select_cmd = f'''select 
                sum(n_hard_parse) as n_hard_parse,
                sum(n_returned_rows) as n_returned_rows,
                sum(n_tuples_fetched) as n_tuples_fetched,  
                sum(n_tuples_returned) as n_tuples_returned,
                sum(n_tuples_inserted) as n_tuples_inserted ,
                sum(n_tuples_updated) as n_tuples_updated, 
                sum(n_tuples_deleted) as n_tuples_deleted, 
                sum(n_blocks_fetched)as n_blocks_fetched, 
                sum(n_blocks_hit)as n_blocks_hit, 
                sum(n_soft_parse) as n_soft_parse 
            from dbe_perf.get_global_full_sql_by_timestamp\
                (now()-interval'5 min', now()) 
            where unique_query_id=(select unique_sql_id 
                from dbe_perf.statement 
                where query like 'analyze {self.table_name}%') 
            minus select 
                n_hard_parse,n_returned_rows,n_tuples_fetched, 
                n_tuples_returned,n_tuples_inserted,n_tuples_updated,
                n_tuples_deleted,n_blocks_fetched,n_blocks_hit,n_soft_parse 
            from dbe_perf.statement 
            where query like 'analyze {self.table_name}%';'''
        select_msg = self.sh_primy.execut_db_sql(select_cmd, dbname='postgres')
        self.logger.info(select_msg)
        row_num = (select_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)

        text = "---step7:插入数据,查询系统视图," \
               "expect:插入数据成功，查询有数据 ---"
        self.logger.info(text)
        sql_cmd = f'insert into {self.table_name} ' \
                  f'select * from {self.table_name} limit 10;' \
                  f'select pg_sleep(30);'
        sql_msg = self.sh_primy.execut_db_sql(sql_cmd)
        self.logger.info(sql_msg)
        self.assertIn(self.constant.INSERT_SUCCESS_MSG,
                      sql_msg, '执行失败:' + text)
        sql_cmd = f'''select 
                n_hard_parse,n_returned_rows,n_tuples_fetched,
                n_tuples_returned, n_tuples_inserted,n_tuples_updated,
                n_tuples_deleted,n_blocks_fetched,n_blocks_hit n_soft_parse 
            from dbe_perf.statement 
            where query like 'insert into {self.table_name}%';'''
        sql_msg = self.sh_primy.execut_db_sql(sql_cmd, dbname='postgres')
        self.logger.info(sql_msg)
        row_num = (sql_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)
        select_cmd = f'''select 
                sum(n_hard_parse) as n_hard_parse,
                sum(n_returned_rows) as n_returned_rows,
                sum(n_tuples_fetched) as n_tuples_fetched,  
                sum(n_tuples_returned) as n_tuples_returned,
                sum(n_tuples_inserted) as n_tuples_inserted ,
                sum(n_tuples_updated) as n_tuples_updated, 
                sum(n_tuples_deleted) as n_tuples_deleted, 
                sum(n_blocks_fetched)as n_blocks_fetched, 
                sum(n_blocks_hit)as n_blocks_hit, 
                sum(n_soft_parse) as n_soft_parse 
            from dbe_perf.get_global_full_sql_by_timestamp\
                (now()-interval'5 min', now()) 
            where unique_query_id=(select unique_sql_id 
                from dbe_perf.statement 
                where query like 'insert into {self.table_name} \
                    select * from {self.table_name} limit%') 
            minus select 
                n_hard_parse,n_returned_rows,n_tuples_fetched, 
                n_tuples_returned,n_tuples_inserted,n_tuples_updated,
                n_tuples_deleted,n_blocks_fetched,n_blocks_hit,n_soft_parse 
            from dbe_perf.statement 
            where query like 'insert into {self.table_name} \
                select * from {self.table_name} limit%';'''
        select_msg = self.sh_primy.execut_db_sql(select_cmd, dbname='postgres')
        self.logger.info(select_msg)
        row_num = (select_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)

        text = "---step8:执行checkpoint,查询系统视图," \
               "expect:执行checkpoint成功，查询有数据 ---"
        self.logger.info(text)
        sql_cmd = f'checkpoint;' \
                  f'select pg_sleep(30);'
        sql_msg = self.sh_primy.execut_db_sql(sql_cmd)
        self.logger.info(sql_msg)
        self.assertIn(self.constant.CHECKPOINT_SUCCESS_MSG,
                      sql_msg, '执行失败:' + text)
        sql_cmd = f'''select 
                        n_hard_parse,n_returned_rows,n_tuples_fetched,
                        n_tuples_returned, n_tuples_inserted,n_tuples_updated,
                        n_tuples_deleted,n_blocks_fetched,
                        n_blocks_hit n_soft_parse 
                    from dbe_perf.statement 
                    where query like 'checkpoint%';'''
        sql_msg = self.sh_primy.execut_db_sql(sql_cmd, dbname='postgres')
        self.logger.info(sql_msg)
        row_num = (sql_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)
        select_cmd = f'''select 
                        sum(n_hard_parse) as n_hard_parse,
                        sum(n_returned_rows) as n_returned_rows,
                        sum(n_tuples_fetched) as n_tuples_fetched,  
                        sum(n_tuples_returned) as n_tuples_returned,
                        sum(n_tuples_inserted) as n_tuples_inserted ,
                        sum(n_tuples_updated) as n_tuples_updated, 
                        sum(n_tuples_deleted) as n_tuples_deleted, 
                        sum(n_blocks_fetched)as n_blocks_fetched, 
                        sum(n_blocks_hit)as n_blocks_hit, 
                        sum(n_soft_parse) as n_soft_parse 
                    from dbe_perf.get_global_full_sql_by_timestamp\
                        (now()-interval'5 min', now()) 
                    where unique_query_id=(select unique_sql_id 
                        from dbe_perf.statement 
                        where query like 'checkpoint%') 
                    minus select 
                        n_hard_parse,n_returned_rows,n_tuples_fetched, 
                        n_tuples_returned,n_tuples_inserted,n_tuples_updated,
                        n_tuples_deleted,n_blocks_fetched,
                        n_blocks_hit,n_soft_parse 
                    from dbe_perf.statement 
                    where query like 'checkpoint%';'''
        select_msg = self.sh_primy.execut_db_sql(select_cmd, dbname='postgres')
        self.logger.info(select_msg)
        row_num = (select_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)

        text = "---step9:执行vacuum,查询系统视图," \
               "expect:执行vacuum成功，查询有数据 ---"
        self.logger.info(text)
        sql_cmd = f'vacuum;' \
                  f'select pg_sleep(30);'
        sql_msg = self.sh_primy.execut_db_sql(sql_cmd)
        self.logger.info(sql_msg)
        self.assertIn(self.constant.VACUUM_SUCCESS_MSG,
                      sql_msg, '执行失败:' + text)
        sql_cmd = f'''select 
                        n_hard_parse,n_returned_rows,n_tuples_fetched,
                        n_tuples_returned, n_tuples_inserted,n_tuples_updated,
                        n_tuples_deleted,n_blocks_fetched,
                        n_blocks_hit n_soft_parse 
                    from dbe_perf.statement 
                    where query like 'vacuum%';'''
        sql_msg = self.sh_primy.execut_db_sql(sql_cmd, dbname='postgres')
        self.logger.info(sql_msg)
        row_num = (sql_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)
        select_cmd = f'''select 
                        sum(n_hard_parse) as n_hard_parse,
                        sum(n_returned_rows) as n_returned_rows,
                        sum(n_tuples_fetched) as n_tuples_fetched,  
                        sum(n_tuples_returned) as n_tuples_returned,
                        sum(n_tuples_inserted) as n_tuples_inserted ,
                        sum(n_tuples_updated) as n_tuples_updated, 
                        sum(n_tuples_deleted) as n_tuples_deleted, 
                        sum(n_blocks_fetched)as n_blocks_fetched, 
                        sum(n_blocks_hit)as n_blocks_hit, 
                        sum(n_soft_parse) as n_soft_parse 
                    from dbe_perf.get_global_full_sql_by_timestamp\
                        (now()-interval'5 min', now()) 
                    where unique_query_id=(select unique_sql_id 
                        from dbe_perf.statement 
                        where query like 'vacuum%') 
                    minus select 
                        n_hard_parse,n_returned_rows,n_tuples_fetched, 
                        n_tuples_returned,n_tuples_inserted,n_tuples_updated,
                        n_tuples_deleted,n_blocks_fetched,
                        n_blocks_hit,n_soft_parse 
                    from dbe_perf.statement 
                    where query like 'vacuum%';'''
        select_msg = self.sh_primy.execut_db_sql(select_cmd, dbname='postgres')
        self.logger.info(select_msg)
        row_num = (select_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)

        text = "---step10:更新数据,查询系统视图," \
               "expect:更新数据成功，查询有数据 ---"
        self.logger.info(text)
        sql_cmd = f"update {self.table_name} set i_class='abc';" \
                  f"select pg_sleep(30);"
        sql_msg = self.sh_primy.execut_db_sql(sql_cmd)
        self.logger.info(sql_msg)
        self.assertIn(self.constant.UPDATE_SUCCESS_MSG,
                      sql_msg, '执行失败:' + text)
        sql_cmd = f'''select 
                        n_hard_parse,n_returned_rows,n_tuples_fetched,
                        n_tuples_returned, n_tuples_inserted,n_tuples_updated,
                        n_tuples_deleted,n_blocks_fetched,
                        n_blocks_hit n_soft_parse 
                    from dbe_perf.statement 
                    where query like 'update {self.table_name} set i_class%';'''
        sql_msg = self.sh_primy.execut_db_sql(sql_cmd, dbname='postgres')
        self.logger.info(sql_msg)
        row_num = (sql_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)
        select_cmd = f'''select 
                        sum(n_hard_parse) as n_hard_parse,
                        sum(n_returned_rows) as n_returned_rows,
                        sum(n_tuples_fetched) as n_tuples_fetched,  
                        sum(n_tuples_returned) as n_tuples_returned,
                        sum(n_tuples_inserted) as n_tuples_inserted ,
                        sum(n_tuples_updated) as n_tuples_updated, 
                        sum(n_tuples_deleted) as n_tuples_deleted, 
                        sum(n_blocks_fetched)as n_blocks_fetched, 
                        sum(n_blocks_hit)as n_blocks_hit, 
                        sum(n_soft_parse) as n_soft_parse 
                    from dbe_perf.get_global_full_sql_by_timestamp\
                        (now()-interval'5 min', now()) 
                    where unique_query_id=(select unique_sql_id 
                        from dbe_perf.statement 
                        where query like 'update {self.table_name} 
                            set i_class%') 
                    minus select 
                        n_hard_parse,n_returned_rows,n_tuples_fetched, 
                        n_tuples_returned,n_tuples_inserted,n_tuples_updated,
                        n_tuples_deleted,n_blocks_fetched,
                        n_blocks_hit,n_soft_parse 
                    from dbe_perf.statement 
                    where query like 'update {self.table_name} set i_class%';'''
        select_msg = self.sh_primy.execut_db_sql(select_cmd, dbname='postgres')
        self.logger.info(select_msg)
        row_num = (select_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)

        text = "---step11:删除数据,查询系统视图," \
               "expect:删除数据成功，查询有数据 ---"
        self.logger.info(text)
        sql_cmd = f"delete from {self.table_name} where i_class='abc';" \
                  f"select pg_sleep(30);"
        sql_msg = self.sh_primy.execut_db_sql(sql_cmd)
        self.logger.info(sql_msg)
        self.assertIn(self.constant.DELETE_SUCCESS_MSG,
                      sql_msg, '执行失败:' + text)
        sql_cmd = f'''select 
                        n_hard_parse,n_returned_rows,n_tuples_fetched,
                        n_tuples_returned, n_tuples_inserted,n_tuples_updated,
                        n_tuples_deleted,n_blocks_fetched,
                        n_blocks_hit n_soft_parse 
                    from dbe_perf.statement 
                    where query like 
                        'delete from {self.table_name} where i_class%';'''
        sql_msg = self.sh_primy.execut_db_sql(sql_cmd, dbname='postgres')
        self.logger.info(sql_msg)
        row_num = (sql_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)
        select_cmd = f'''select 
                        sum(n_hard_parse) as n_hard_parse,
                        sum(n_returned_rows) as n_returned_rows,
                        sum(n_tuples_fetched) as n_tuples_fetched,  
                        sum(n_tuples_returned) as n_tuples_returned,
                        sum(n_tuples_inserted) as n_tuples_inserted ,
                        sum(n_tuples_updated) as n_tuples_updated, 
                        sum(n_tuples_deleted) as n_tuples_deleted, 
                        sum(n_blocks_fetched)as n_blocks_fetched, 
                        sum(n_blocks_hit)as n_blocks_hit, 
                        sum(n_soft_parse) as n_soft_parse 
                    from dbe_perf.get_global_full_sql_by_timestamp\
                        (now()-interval'5 min', now()) 
                    where unique_query_id=(select unique_sql_id 
                        from dbe_perf.statement 
                        where query like 'delete from {self.table_name} \
                            where i_class%') 
                    minus select 
                        n_hard_parse,n_returned_rows,n_tuples_fetched, 
                        n_tuples_returned,n_tuples_inserted,n_tuples_updated,
                        n_tuples_deleted,n_blocks_fetched,
                        n_blocks_hit,n_soft_parse 
                    from dbe_perf.statement 
                    where query like 'delete from {self.table_name} \
                        where i_class%';'''
        select_msg = self.sh_primy.execut_db_sql(select_cmd, dbname='postgres')
        self.logger.info(select_msg)
        row_num = (select_msg.splitlines()[-1].strip())[1]
        row_num = int(row_num)
        self.assertTrue(row_num >= 1, '执行失败:' + text)

    def tearDown(self):
        text = '---step12:环境清理，expect:成功---'
        self.logger.info(text)
        text = '---检查参数，恢复原值:enable_copy_server_files---'
        self.logger.info(text)
        check_copy = self.sh_primy.execut_db_sql(self.show_copy_cmd)
        self.logger.info(check_copy)
        current = check_copy.splitlines()[-2].strip()
        if self.copy_default != current:
            result = self.sh_primy.execute_gsguc('reload',
                                                 self.constant.GSGUC_SUCCESS_MSG,
                                                 f'{self.config_copy}={self.copy_default}')
            self.assertTrue(result, '参数恢复失败')
        show_copy_msg = self.sh_primy.execut_db_sql(self.show_copy_cmd)
        self.logger.info(show_copy_msg)

        text = '---检查参数，恢复原值:instr_unique_sql_count---'
        self.logger.info(text)
        check_instr = self.sh_primy.execut_db_sql(self.show_instr_cmd)
        self.logger.info(check_instr)
        current = check_instr.splitlines()[-2].strip()
        if self.instr_default != current:
            result = self.sh_primy.execute_gsguc('reload',
                                                 self.constant.GSGUC_SUCCESS_MSG,
                                                 f'{self.config_instr}={self.instr_default}')
            self.assertTrue(result, '参数恢复失败')
        show_instr_msg = self.sh_primy.execut_db_sql(self.show_instr_cmd)
        self.logger.info(show_instr_msg)

        text = '---删除表，删除文件夹---'
        self.logger.info(text)
        drop_cmd = f'''drop table {self.table_name};'''
        drop_msg = self.sh_primy.execut_db_sql(drop_cmd)
        self.logger.info(drop_msg)
        rm_cmd = f'rm -rf {self.table_path};'
        self.rootNode.sh(rm_cmd).result()
        self.assertIn(self.constant.DROP_TABLE_SUCCESS,
                      drop_msg, '执行失败:' + text)
        self.assertFalse(os.path.exists(self.table_path), '执行失败:' + text)
        self.common.equal_sql_mdg(show_copy_msg, self.config_copy,
                                  self.copy_default, '(1 row)', flag='1')
        self.common.equal_sql_mdg(show_instr_msg, self.config_instr,
                                  self.instr_default, '(1 row)', flag='1')
        self.logger.info(
            '---Opengauss_Function_Fullsql_Case0014 finish---')
